package se.statemachine.fsm.interfacestyle;

import se.statemachine.fsm.interfacestyle.state.LockedState;
import se.statemachine.fsm.interfacestyle.state.UnlockedState;

/**
 * @author erik
 * 
 */
public class TurnstileFSM implements TurnstileEvents{
	
	public static final UnlockedState unlocked = new UnlockedState();
	public static final LockedState locked = new LockedState();
	
	// default is locked
	private static TurnstileState state = locked;
	
	private static Turnstile turnstile = new Turnstile();
		
	public static void setState(TurnstileState state){		
		TurnstileFSM.state = state;
	}
	
	public static TurnstileState getState(){
		return state;
	}
		
	// Events
	public void coin(){
		state.coin(turnstile);
	}
	
	public void pass(){
		state.pass(turnstile);
	}
	
	public String getCurrentState(){
		return state.toString();
	}


}
